%-------------------------------------------------------------------------
% system initialization script
% @attention
% this script should run before every other scripts and functions
%-------------------------------------------------------------------------
if ~exist('g_config')
    %---------------------------------------------------------------------
    % general startup initialization
    % for all applications
    %---------------------------------------------------------------------
    disp( 'init start...' );

    global g_config;
    
    g_config.rootdir = fun_getrootdir();
    g_config.datadir = [g_config.rootdir, '\data'];
    g_config.datadir = 'D:\data';
    g_config.tempdir = [g_config.rootdir, '\temp'];
    g_config.workdir = [g_config.rootdir, '\source\experiment'];
    g_config.workdir = [g_config.rootdir, '\work'];
    g_config.nogui = 0;

    path( g_config.rootdir, path );
    path( [g_config.rootdir, '\source\contrib\tisean4m'], path );
    path( [g_config.rootdir, '\source\contrib\rplot'], path );
    path( [g_config.rootdir, '\source\contrib\wavelet_estimation'], path );
    path( [g_config.rootdir, '\source\contrib'], path );
    path( [g_config.rootdir, '\source\algo'], path );
    path( [g_config.rootdir, '\source\input'], path );
    path( [g_config.rootdir, '\source\output'], path );
    path( [g_config.rootdir, '\source\ui'], path );
    path( [g_config.rootdir, '\source\common\data'], path );
    path( [g_config.rootdir, '\source\common'], path );
    path( [g_config.rootdir, '\source\experiment'], path );
    path( [g_config.rootdir, '\source\conf'], path );
    path( [g_config.rootdir, '\source'], path );
    path( [g_config.rootdir, '\work'], path );

    %---------------------------------------------------------------------
    % specific startup initialization
    % for specific applications
    %---------------------------------------------------------------------

    g_exp = [];
    g_stat = [];
    % t4m_init;
    g_config.tiseanroot = 'D:\binx\research\tisean-3.0.0\bin\';

    cd( g_config.workdir );
    disp( 'init end.' );
    % disp( ['current working directory in g_config is setted to: ' g_config.workdir ] );
    % disp( ['current working directory of matlab is changed to: ' pwd ] );
end
